home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / GLX / texvol / init.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  4.0 KB  |  171 lines

  1. /*
  2.  * Copyright (C) 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. /*----------------------------------------------------------------------------
  18.  * 
  19.  * file   : init.c 
  20.  * 
  21.  * Author : Yusuf Attarwala
  22.  * Date   : Sep 93
  23.  * 
  24.  *---------------------------------------------------------------------------*/
  25.  
  26. #include "globals_vol.h"
  27.  
  28. initFog()
  29. {
  30.     fog          = 0;
  31.     fogMode      = FG_VTX_EXP;
  32.     fogDensity   = 0.001;
  33.     fogRGB[_R]   = 0.01;
  34.     fogRGB[_G]   = 0.01;
  35.     fogRGB[_B]   = 0.01;
  36.     startFog     = near;
  37.     endFog       = far;
  38. }
  39.  
  40. defFog()
  41. {
  42.     startFog     = far;
  43.     endFog       = near;
  44.  
  45.     switch(fogMode) {
  46.     case FG_VTX_EXP :
  47.     case FG_PIX_EXP :
  48.     case FG_VTX_EXP2 :
  49.     case FG_PIX_EXP2 :
  50.         fogParams[0] = fogDensity;
  51.         fogParams[1] = fogRGB[_R];
  52.         fogParams[2] = fogRGB[_G];
  53.         fogParams[3] = fogRGB[_B];
  54.         break;
  55.     case FG_VTX_LIN :
  56.     case FG_PIX_LIN :
  57.         fogParams[0] = startFog;
  58.         fogParams[1] = endFog;
  59.         fogParams[2] = fogRGB[_R];
  60.         fogParams[3] = fogRGB[_G];
  61.         fogParams[4] = fogRGB[_B];
  62.         break;
  63.     }
  64.     fogvertex(fogMode,fogParams);
  65. }
  66.  
  67.  
  68. void
  69. initClipplanes()
  70. {
  71.     register int i,j;
  72.  
  73.     displayClipPlanes = 0;  /* display planes by default */
  74.     doClipping  = 0;
  75.     activeClipPlane = 0;
  76.     for (i=0;i<MAXCLIP;i++) {
  77.     clip[i].onOff = 0;
  78.     for (j=0;j<4;j++) {
  79.         clip[i].coeff[j] = 0.0;
  80.     }
  81.     clip[i].onOff = 0;
  82.     for (j=0;j<3;j++) {
  83.         clip[i].xyz[j] = 0.0;
  84.     }
  85.     }
  86.  
  87.     /* initialize these planes to be parallel to model axes */
  88.  
  89.     clip[0].coeff[0] =  1.0;
  90.     clip[1].coeff[0] =  -1.0;
  91.  
  92. /* for oblique 
  93.     clip[0].coeff[0] =  clip[0].coeff[1] =0.707;
  94.     clip[1].coeff[0] =  clip[1].coeff[1] =-0.707;
  95. */
  96.  
  97.     clip[2].coeff[1] =  1.0;
  98.     clip[3].coeff[1] =  -1.0;
  99.     clip[4].coeff[2] =  1.0;
  100.     clip[5].coeff[2] =  -1.0;
  101. }
  102.  
  103. void
  104. initGlobals()
  105. {
  106.     int i,j;
  107.     extern unsigned long packc();
  108.  
  109.     refresh = 0;
  110.     screenAxes = 1;
  111.     trackBall = 0;
  112.     drawMode  = WIREFRAME;  /* or start as WIREFRAME */
  113.     drawMode  = TEXTURED;  /* or start as WIREFRAME */
  114.     drawAxis  = 0;
  115.     doLighting = 0;
  116.     degenMode = 0;
  117.     doubleBuffer = 1;
  118.     dontBlend   = 0;
  119.     lightWeight = 0;
  120.     lightWeightCount = 1;
  121.     moveSlice   = 0;
  122.     lockAView   = 0;
  123.     obliquePlane = 0;
  124.  
  125.     cpackAlpha = 0xff;
  126.     cpackRed   = 0xff;
  127.     cpackGreen = 0xff;
  128.     cpackBlue  = 0xff;
  129.     cpackValue = packc(cpackAlpha,cpackBlue,cpackGreen,cpackRed);
  130.  
  131.     copy_matrix(identity,mmat);
  132.     copy_matrix(identity,vmat);
  133.     copy_matrix(mmat,reset_mmat);
  134.     copy_matrix(vmat,reset_vmat);
  135.  
  136.     initClipplanes();
  137.     initFog();
  138. }
  139.  
  140. void
  141. obliquePlaneToggle()
  142. {
  143.     int i,j;
  144.     obliquePlane  = !obliquePlane;
  145.     if (obliquePlane) {
  146.         clip[0].coeff[0] =  clip[0].coeff[1] =0.707;
  147.         clip[1].coeff[0] =  clip[1].coeff[1] =-0.707;
  148.  
  149.         clip[2].coeff[1] =  clip[2].coeff[2] =0.707;
  150.         clip[3].coeff[1] =  clip[3].coeff[2] =-0.707;
  151.  
  152.         clip[4].coeff[2] =  clip[4].coeff[0] =0.707;
  153.         clip[5].coeff[2] =  clip[5].coeff[0] =-0.707;
  154.     }
  155.     else {
  156.         for (i=0;i<MAXCLIP;i++) {
  157.         for (j=0;j<4;j++) {
  158.             clip[i].coeff[j] = 0.0;
  159.             }
  160.     }
  161.         clip[0].coeff[0] =  1.0;
  162.         clip[1].coeff[0] =  -1.0;
  163.  
  164.         clip[2].coeff[1] =  1.0;
  165.         clip[3].coeff[1] =  -1.0;
  166.  
  167.         clip[4].coeff[2] =  1.0;
  168.         clip[5].coeff[2] =  -1.0;
  169.     }
  170. }
  171.